package gunPowderMod.block.renderer;

import net.minecraft.src.Block;
import net.minecraft.src.BlockRedstoneWire;
import net.minecraft.src.IBlockAccess;
import net.minecraft.src.RenderBlocks;
import net.minecraft.src.Tessellator;
import cpw.mods.fml.client.registry.ISimpleBlockRenderingHandler;

public class FuseRenderer implements ISimpleBlockRenderingHandler {

	@Override
	public void renderInventoryBlock(Block block, int metadata, int modelID, RenderBlocks renderer) {
		// TODO Auto-generated method stub

	}

	@Override
	public boolean renderWorldBlock(IBlockAccess world, int x, int y, int z, Block block, int modelId, RenderBlocks renderer) {
		Block par1Block = block;
		Tessellator tesselator = Tessellator.instance;
		tesselator.setBrightness(par1Block.getMixedBrightnessForBlock(world, x, y, z));
		
		int var6 = world.getBlockMetadata(x, y, z);
		float var9 = (float) var6 / 15.0F;
		float var10 = var9 * 0.6F + 0.4F;
		
		if (var6 == 0) {
			var10 = 0.3F;
		}

		float var11 = var9 * var9 * 0.7F - 0.5F;
		float var12 = var9 * var9 * 0.6F - 0.7F;

		tesselator.setColorOpaque_F(var10, var11, var12);
		double var15 = 0, var19 = var15;
		double xStretch = 1d/16d;
		double yStretch = 1d/16d;

		float modifiedXLower = (float) (x + 0);
		float modifiedXHigher = (float) (x + 1);
		float modifiedZLower = (float) (z + 0);
		float modifiedZHigher = (float) (z + 1);

		// render top face
		tesselator.addVertexWithUV((double) modifiedXHigher, (double) y + 0.015625D, (double) modifiedZHigher, 1d/16, 1d/16);
		tesselator.addVertexWithUV((double) modifiedXHigher, (double) y + 0.015625D, (double) modifiedZLower, 1d/16, 0);
		tesselator.addVertexWithUV((double) modifiedXLower, (double) y + 0.015625D, (double) modifiedZLower, 0, 0);
		tesselator.addVertexWithUV((double) modifiedXLower, (double) y + 0.015625D, (double) modifiedZHigher, 0, 1d/16);
		// render bottom face (transparent)
		tesselator.setColorOpaque_F(1f, 1f, 1f);
		tesselator.addVertexWithUV((double) modifiedXHigher, (double) y + 0.015625D, (double) modifiedZHigher, 1d/16, 1d/16);
		tesselator.addVertexWithUV((double) modifiedXHigher, (double) y + 0.015625D, (double) modifiedZLower, 1d/16, 0);
		tesselator.addVertexWithUV((double) modifiedXLower, (double) y + 0.015625D, (double) modifiedZLower, 0, 0);
		tesselator.addVertexWithUV((double) modifiedXLower, (double) y + 0.015625D, (double) modifiedZHigher, 0, 1d/16);
		return true;
	}

	@Override
	public boolean shouldRender3DInInventory() {
		// TODO Auto-generated method stub
		return false;
	}

	@Override
	public int getRenderId() {
		// TODO Auto-generated method stub
		return 0;
	}

}
